package RobotPlayer
{
	import BasicEngine.Vector2D;
	import flash.geom.Point;
	import GameLogic.Game;
	/**
	 * 机器人工厂
	 * 负责机器人的建造,改装,销毁管理
	 */
	public class RobotFactory
	{
		public function RobotFactory()
		{
		}
		/**
		 * 创建机器人
		 */
		public static function CreatRobot(_x:int,_y:int):BaseRobot
		{
			var part:RobotPart = new RobotPart("LeftCannon",0,-18,-20,0.6);
			part.AddStateData("开火", 100, [1043, 1044, 1044,1045, 1046],true,false);
			var part2:RobotPart = new RobotPart("RightCannon",0,-18,-20,0.6);
			part2.AddStateData("开火", 100, [1043, 1044, 1044,1045, 1046],true,false);
			var part3:RobotPart = new RobotPart("Cockpit",0,-16,-20);
			part3.AddStateData("正常状态", 100, [1014],true,true);
			var part4:RobotPart = new RobotPart("Chassis", 0, -23, -20);
			part4.AddStateData("正常状态", 40, [1022,1023,1024,1025,1027,1028,1029,1030,1031,1032,1033,1035,1036,1037],true);
			
			var BottomModule:RobotModule = new RobotModule("BottomModule",0,0);
			BottomModule.AddPart(part4, new Point(0, 0));
			var TopModule:RobotModule = new RobotModule("TopModule",0,0,180,0.7);
			TopModule.AddPart(part3, new Point(0, 0));
			TopModule.AddPart(part, new Point(-20, 0));
			TopModule.AddPart(part2, new Point(20, 0));
			var robot:BaseRobot = new BaseRobot(new Vector2D(0, 0), 1000, 2, 120);
			robot.AssemblyModule(BottomModule);
			robot.AssemblyModule(TopModule);
			robot.Pos.X = _x;
			robot.Pos.Y = _y;
			Game.PlayerCanvas.addChild(robot.Canvas);
			return robot;
		}
		/**
		 * 装配零件
		 */
		public static function AssemblyPart(_robot:BaseRobot, _moduleName:String, _x:int, _y:int, _part:RobotPart):void
		{
			var module:RobotModule = _robot.Modules[_moduleName];
			module.AddPart(_part, new Point(_x, _y));
		}
		/**
		 * 卸载零件
		 */
		public static function RemovePart(_robot:BaseRobot,_moduleName:String, _partName:String):void
		{
			var module:RobotModule = _robot.Modules[_moduleName];
			module.RemovePart(_partName);
		}
	}
}